package com.lwq.util;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;

import com.lwq.util.DrawUtil;

public class ImageContainer {
	private static ImageContainer instance = null;
	private Map<String, Image> imageMap = null;
	private int imageIndex = 0;

	public ImageContainer() {
		imageMap = new HashMap<String, Image>();
	}

	public static ImageContainer getInstance() {
		if (instance == null) {
			instance = new ImageContainer();
		}
		return instance;
	}

	public Image getImage(String path) {
		Image im = null;
		if (imageMap.containsKey(path)) {
			return imageMap.get(path);
		} else {
			im = DrawUtil.getImage(path);
			if (im == null) {
				imageMap.put(path, im);
			}
			return im;
		}
	}

}
